package controller.product;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import view.product.ProductMainPanel;

public class ProductTypeController implements ItemListener {
	private ProductMainPanel gui;

	public ProductTypeController(ProductMainPanel prod_mainpanel) {
		this.gui = prod_mainpanel;
	}

	private void chooseType() {
		switch (gui.getCbbProdProducttype().getSelectedIndex()) {
		case 0:
		case 1:
			gui.getPnProdSub().remove(gui.getPnCurrent());
			gui.setPnCurrent(gui.getPnProdMobile());
			gui.getPnProdSub().add(gui.getPnCurrent());
			gui.getPnCurrent().setBounds(0, 0, 341, 215);

			break;
		case 2:
			gui.getPnProdSub().remove(gui.getPnCurrent());
			gui.setPnCurrent(gui.getPnProdLaptop());
			gui.getPnProdSub().add(gui.getPnCurrent());
			gui.getPnCurrent().setBounds(0, 0, 341, 215);
			break;

		}
		gui.updateUI();
	}

	@Override
	public void itemStateChanged(ItemEvent e) {
		chooseType();

	}
}
